﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PartyWithInheritance
{
    public partial class Form1 : Form
    {
        private DinnerParty _dinnerParty;

        private BirthdayParty _birthdayParty;

        public Form1()
        {
            InitializeComponent();

            _dinnerParty = new DinnerParty((int)NudPeople.Value, ChkFancy.Checked, ChkHealthy.Checked);

            DisplayDinnerPartyCost();

            _birthdayParty = new BirthdayParty((int)NudPeopleBirthday.Value, ChkFancyBirthday.Checked, TxtCakeWriting.Text);

            DisplayBirthdayPartyCost();
        }

        private void DisplayDinnerPartyCost()
        {
            LblCost.Text = _dinnerParty.Cost.ToString("C");
        }

        private void NudPeople_ValueChanged(object sender, EventArgs e)
        {
            _dinnerParty.NumberOfPeople = (int)NudPeople.Value;
            DisplayDinnerPartyCost();
        }

        private void ChkFancy_CheckedChanged(object sender, EventArgs e)
        {
            _dinnerParty.FancyDecorations = ChkFancy.Checked;
            DisplayDinnerPartyCost();
        }

        private void ChkHealthy_CheckedChanged(object sender, EventArgs e)
        {
            _dinnerParty.HealthyOption = ChkHealthy.Checked;
            DisplayDinnerPartyCost();
        }

        private void DisplayBirthdayPartyCost()
        {
            LblBirthdayTooLong.Visible = _birthdayParty.CakeWritingTooLong;
            var cost = _birthdayParty.Cost;
            LblCostBirthday.Text = cost.ToString("C");
        }

        private void NudPeopleBirthday_ValueChanged(object sender, EventArgs e)
        {
            _birthdayParty.NumberOfPeople = (int)NudPeopleBirthday.Value;
            DisplayBirthdayPartyCost();
        }

        private void ChkFancyBirthday_CheckedChanged(object sender, EventArgs e)
        {
            _birthdayParty.FancyDecorations = ChkFancyBirthday.Checked;
            DisplayBirthdayPartyCost();
        }

        private void TxtCakeWriting_TextChanged(object sender, EventArgs e)
        {
            _birthdayParty.CakeWriting = TxtCakeWriting.Text;
            DisplayBirthdayPartyCost();
        }
    }

}
